/**
 * 
 */
package duckHunter.app;

import java.util.Random;

/**
 * GameContext is a class used to manages the number of cartouche and score
 * @author masterfab
 *
 */
public class GameContext {
	public int score = 0;
	public int nbCartouche = 20;
	public static int highScore;

	/**
	 * @param score the score to set
	 */
	public void setScore(int score) {
		this.score = score;
	}

	/**
	 * @param nbLife the nbLife to set
	 */
	public void setNbCartouche(int nbCar) {
		this.nbCartouche = nbCar;
	}

	/**
	 * Permet la generation d'entiers aleatoires.
	 */
	private Random rd = new Random();

	/**
	 * Unique instance de la classe, typique du singleton
	 */
	public static GameContext instance;

	/**
	 * Constructeur privé, typique du singleton
	 */
	private GameContext() {
	}

	/**
	 * Permet la récupération de l'instance unique, typique du singleton
	 * 
	 * @return Le contexte
	 */
	public static GameContext getInstance() {
		if (instance == null) {
			instance = new GameContext();
		}
		return instance;
	}

	public int getNbCartouche() {
		return nbCartouche;
	}

	public int getScore() {
		return score;
	}

	public Random getRd() {
		return rd;
	}

	/**
	 * Incrémente le score
	 * 
	 * @param score
	 */
	public void incScore(int score) {
		this.score += score;
	}

	/**
	 * Appelé a perte d'une vie
	 */
	public void decNBCartouche() {
		this.nbCartouche -= 1;
	}

	public int getHighScore(){
		return highScore;
	}

	public void setHighScore(int score){
		highScore=score;
	}
	public void updateHighScore(){
		if (score>highScore){
			highScore = score;
		}
	}
	

}
